package com.springboot.erp.controller;

import com.springboot.erp.common.CommonResult;
import com.springboot.erp.entity.JshMaterialCurrentStock;
import com.springboot.erp.entity.TransferRequest;
import com.springboot.erp.service.JshMaterialCurrentStockService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;

@RestController
@RequestMapping("/materialChange")
@Slf4j
public class MaterialChangeController {
    @Resource
    private JshMaterialCurrentStockService jshCurrentService;
    @PutMapping
    public CommonResult changeMaterial(@RequestBody TransferRequest transferRequest) {
        log.info("jshMaterialCurrentStock: {}", transferRequest);
        jshCurrentService.changeCurrentNumber(
                transferRequest.getFromStock(),
                transferRequest.getToStock(),
                transferRequest.getNumber()
        );
        return new CommonResult(0, "success", null);


    }
    @GetMapping("/{id}")
    public JshMaterialCurrentStock findById(@PathVariable Integer id)
    {
        return jshCurrentService.findById(id);
    }
}
